%define lver 4_11_2023_12
%define lfile lvh_software_levenhuklite_%{lver}
%define ldir %{_libexecdir}/%{name}

Summary(ru_RU.UTF-8):	ПО для цифрового микроскопа Levenhuk
Summary:	LevenhukLite software
Name:		levenhuklite
Version:	%(echo %{lver} | tr _ .)
Release:	1
License:	GPLv3
Group:		System/Configuration/Hardware
Url:		https://www.levenhuk.ru/products/microscope-levenhuk-d740t-5-1mpix
Source0:	https://www.levenhuk.ru/products/materials/0/%{lfile}.zip

BuildRequires: unzip

ExclusiveArch: x86_64

%description
LevenhukLite microscope
https://www.levenhuk.ru/products/microscope-levenhuk-d740t-5-1mpix
Download all software:
https://www.levenhuk.ru/products/materials/0/lvh_software_levenhuklite_4_11_2022_01.zip

%description -l ru_RU.UTF-8
Микроскоп Levenhuk D740T – цифровой микроскоп с тринокулярной насадкой.
https://www.levenhuk.ru/products/microscope-levenhuk-d740t-5-1mpix
Набор программного обеспечения:
https://www.levenhuk.ru/products/materials/0/lvh_software_levenhuklite_4_11_2022_01.zip

%files
%{ldir}
%{_datadir}/applications/LevenhukLite.desktop
%{_iconsdir}/hicolor/128x128/apps/LevenhukLite.png
%{_udevrulesdir}/99-levenhukcam.rules
%{_bindir}/LevenhukLite

#------------------------------------------------------------------

%prep
%setup -T -c
cp %sources .
unzip %{lfile}.zip
tar xvfj %{lfile}/LevenhukLite.x64.tar.bz2
sed -n -e '1,/^exit 0$/!p' LevenhukLite.x64.sh > LevenhukLite.tgz
tar xvf LevenhukLite.tgz

%install
sed -i 's,/usr/local/LevenhukLite/,,g' LevenhukLite.desktop
sed -i 's/\.png//g' LevenhukLite.desktop
echo 'Comment=Software for Levenhuk' >> LevenhukLite.desktop
echo 'Comment[ru]=Приложение для работы с микроскопом Levenhuk' >> LevenhukLite.desktop
echo 'Categories=AudioVideo;Video;Recorder;' >> LevenhukLite.desktop

mkdir -p %{buildroot}%{ldir}
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_datadir}/applications

cp -a i18n %{buildroot}%{ldir}/
install -m0755 LevenhukLite %{buildroot}%{ldir}/LevenhukLite
install -m0755 liblevenhukcam.so %{buildroot}%{ldir}/liblevenhukcam.so
install -m0755 liblevenhuknam.so %{buildroot}%{ldir}/liblevenhuknam.so
install -Dpm0644 LevenhukLite.png %{buildroot}%{_iconsdir}/hicolor/128x128/apps/LevenhukLite.png
install -Dm0644 99-levenhukcam.rules %{buildroot}%{_udevrulesdir}/99-levenhukcam.rules
install -pm0644 LevenhukLite.desktop %{buildroot}%{_datadir}/applications/LevenhukLite.desktop

cat > %{buildroot}%{_bindir}/LevenhukLite << ENDF
#!/bin/bash
exec %_libexecdir/%{name}/LevenhukLite
ENDF
chmod +x %{buildroot}%{_bindir}/LevenhukLite
